/**
 * Created by MetaLab_Gu on 2016/5/4.
 */
angular.module('metalabPartnerApp').directive("metaScrollTop", function ($window) {
    return function (scope, element, attrs) {
        element.on('click', function () {
            $('html,body').animate({
                scrollTop: '0px'
            }, 200);
        });
        var threshold = attrs['metaScrollThreshold'] ? attrs['metaScrollThreshold'] : 100;
        angular.element($window).bind("scroll", function () {
            if (this.pageYOffset >= threshold) {
                scope.visible = true;
            } else {
                scope.visible = false;
            }
            scope.$apply();
        });
    };
});
